package com.archgeek.rpc.proxy.custom;

import com.archgeek.rpc.service.ProductService;
import com.archgeek.rpc.service.ProductServiceImpl;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

/**
 * @author pizhihui
 * @date 2024-05-22 23:37
 */
public class CustomClient {




    public static void main(String[] args) throws IOException, ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
//        IUserInfoSerivce userInfoSerivce = new UserInfoSerivceImpl();
//
//        Object o = new UserInfoSerivceImpl();
//
//        IUserInfoSerivce service = (IUserInfoSerivce) MyProxy.newProxyInstance(new MyClassLoader(),
//                userInfoSerivce.getClass().getInterfaces()[0],
//                new CustomInvocationHandler(o));
//
//        Response response = service.queryUserInfoById(new Request().setName("custom xxxx"));
//        System.out.println(response);


        ProductService productService = new ProductServiceImpl();

        Object o = new ProductServiceImpl();

        ProductService service = (ProductService) MyProxy.newProxyInstance(new MyClassLoader(), productService.getClass().getInterfaces()[0], new CustomInvocationHandler(o));
        service.addProduct();

//        ProductService productService = new ProductServiceImpl();
//        ProductService proxy = (ProductService) new CustomInvocationHandler().getInstance(productService);
//        proxy.addProduct();


    }
}
